// import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
    state: localStorage.getItem('state') ? JSON.parse(localStorage.getItem('state')) : {
        token: '',
        maxRole: '',
        user:'',
        logo:'',
        schoolName:'',
        schoolId:'',
        loginInfo:'',
        jyzid:'',
        todocnt:'',
        msgcnt:'',
        selectedRole:''
    },
    getters: {
        getToken(state) {
            return state.token
        },
        getMaxRole(state) {
            return state.maxRole
        },
        getUser(state) {
            return state.user
        },
        getLogo(state) {
            return state.logo
        },
        getSchoolName(state) {
            return state.schoolName
        },
        getLoginInfo(state){
            return state.loginInfo
        },
        getJyzid(state){
            return state.jyzid
        },
        getSchoolId(state){
            return state.schoolId
        },
        getTodocnt(state){
            return state.todocnt
        },
        getMsgcnt(state){
            return state.msgcnt
        },
        getSelectedRole(state){
            return state.selectedRole
        }
    },
    mutations: {
        setToken(state, n) {
            localStorage.setItem('token', JSON.stringify(n));
            state.token = n;
        },
        setMaxRole(state, n){
            localStorage.setItem('maxRole', JSON.stringify(n));
            state.maxRole = n;
        },
        setUser(state, n){
            localStorage.setItem('user', JSON.stringify(n));
            state.user = n;
        },
        setLogo(state, n){
            localStorage.setItem('logo', JSON.stringify(n));
            state.logo = n;
        },
        setSchoolName(state, n){
            localStorage.setItem('schoolName', JSON.stringify(n));
            state.schoolName = n;
        },
        setLoginInfo(state, n){
            localStorage.setItem('loginInfo', JSON.stringify(n));
            state.loginInfo = n;
        },
        setJyzid(state, n){
            localStorage.setItem('jyzid', JSON.stringify(n));
            state.jyzid = n;
        },
        setSchoolId(state, n){
            localStorage.setItem('schoolId', JSON.stringify(n));
            state.schoolId = n;
        },
        setTodocnt(state, n){
            localStorage.setItem('todocnt', JSON.stringify(n));
            state.todocnt = n;
        },
        setMsgcnt(state, n){
            localStorage.setItem('msgcnt', JSON.stringify(n));
            state.msgcnt = n;
        },
        setSelectedRole(state, n){
            localStorage.setItem('selectedRole', JSON.stringify(n));
            state.selectedRole = n;
        }

    }
})
